<div class="row">
    <div class="col-md-12">
        <div class="widget stacked">
            <div class="widget-header">
                <i class="icon-list"></i>
                <h3><?php echo isset($title_for_layout)?$title_for_layout:$this->l('List of prescriptions'); ?></h3>
            </div> <!-- /.widget-header -->
            <div class="widget-content">
                <form action="<?php echo base_url('Doctor/Prescription/'); ?>" method="get" style="width: 100%;">
                    <div class="form-group">
                        <span class="col-md-8">
                            <a class="btn btn-success" href="<?php echo base_url('Doctor/Prescription/create'); ?>"><?php echo $this->l('Add a prescription'); ?></a>
                        </span>
                        
                        <div id="search" class="col-md-4">
                            <label class="col-md-4" for="inputquery" style=" line-height: 34px; ">
                                <?php echo $this->l('Search'); ?>
                            </label>
                        
                            <div class="input-group">
                                <input id="inputquery" class="form-control" type="text" name="q" value="<?php //echo $q; ?>" />
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="submit"><?php echo $this->l('Go!'); ?></button>
                                </span>
                            </div><!-- /input-group -->
                        </div>
                        <input type="hidden" name="filter_reset" value="1" />
                        <input type="hidden" name="order_reset" value="1" />
                    </div>
                    <div class="clearfix"></div>
                </form>
                <div class="collapse navbar-collapse navbar-ex1-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown-submenu"><a tabindex="-1" href="<?php echo base_url('Doctor/Prescription/?filter_reset=1'); ?>"><?php echo $this->l('All prescriptions'); ?></a></li>
                        <li><a href="<?php echo base_url('Doctor/Prescription/?filter_by=status&filter_val=0'); ?>"><?php echo $this->l('Prescriptions off'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Prescription/?filter_by=status&filter_val=1'); ?>"><?php echo $this->l('Prescriptions on'); ?></a></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
                
                <br />  

                <section id="tables">
                    <div class="page-header">
                        <h3><?php echo $title; ?></h3>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-bordered table-condensed">
                            <thead>
                              <tr>
                                <th>#</th>
                                <th><?php echo $this->l('Status'); ?></th>
                                <th><?php echo $this->l('Content'); ?></th>
                                <th><?php echo $this->l('Patient'); ?></th>
                                <th><?php echo $this->l('Date'); ?></th>
                                <th><?php echo $this->l('Actions'); ?></th>
                              </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($items as $key => $value) { ?>
                                    <tr>
                                        <td><?php echo $value->id_prescription; ?></td>
                                        <td><?php echo $value->status == 1 ? $this->l('On') : $this->l('Off'); ?></td>
                                        <td><?php echo $value->content; ?></td>
                                        <td><?php echo $value->lastname.' '.$value->firstname; ?></td>
                                        <td>
                                            <?php $date = date_create_from_format('Y-m-d H:i:s', $value->date_add);
                                            echo date_format($date, 'd F Y').' at ';
                                            echo date_format($date, 'H:i A'); ?>
                                        </td>
                                        <td>
                                           <a class="btn btn-xs btn-success" href="<?php echo site_url('Doctor/Prescription/Update/?id='.$value->id_prescription); ?>"><i class="icon icon-edit"></i></a>
                                            <a class="btn btn-xs btn-primary" href="<?php echo site_url('Doctor/Prescription/send/?id='.$value->id_prescription.'&patient='.$value->id_patient); ?>"><i class="icon icon-envelope"></i></a>
                                            <a class="btn btn-xs <?php echo $value->status == 1 ? 'btn-danger' : 'btn-success'; ?>" 
                                                href="<?php echo $value->status == 1 ? site_url('Doctor/Prescription/stop/?act=on&id='.$value->id_prescription) : site_url('Doctor/Prescription/stop/?act=off&id='.$value->id_prescription); ?>"
                                                title="<?php echo $this->l('Change the status of this prescription'); ?>">
                                                <i class="icon icon-<?php echo $value->status == 1 ? 'remove-sign' : 'ok'; ?>"></i>
                                            </a>
                                        </td>
                                    </tr>
                                <?php }  ?>                                                    
                            </tbody>
                        </table>
                    </div>
                </section>
                <?php include(((BASEPATH == '/')?'':dirname(BASEPATH)).'/'.APPPATH.'views/Templates/pagination.php'); ?>
            </div><!-- box-content -->
        </div><!-- /.box -->
    </div><!-- /.col (MAIN) -->
</div>
